﻿#ifndef __SS_THREAD_POOL_H__
#define __SS_THREAD_POOL_H__
//#include "../../container/ssList.h"
#include "../../container/ssNumArray.h"
#include "ssWorkThread.h"


namespace StarSeeker
{

class ssThreadPool
{
	friend class ssWorkThread;
public:
	ssThreadPool();
	virtual ~ssThreadPool();

	//启动线程组
	void Start();
	//退出线程组
	void Exit();
	//发送消息
	void PostMsg(ssMsg_s &m);
	void PostMsg(u32 msgID, u32 subID, ulint param1, ulint param2, ulint param3);
	//增加工作线程，必须在线程未启动状态
	void AddThread(ssWorkThread* pThread);
	void AddThreads(ssWorkThread* pThreadArr[], u32 count);

protected:
	ssNumArray<ssWorkThread*>	m_threads;
	ssThreadLock				m_mutex;		//互斥量，配合条件变量使用
	ssThreadCondition			m_condGet;		//读取条件变量
	ssList<ssMsg_s>				m_msgList;		//消息队列

	static int					s_weight[32];
};


}
#endif
